<?php
class BeiyongerModel extends Action{
	
	//公版
	public function getmo($beiyongerid){
		$info=collectinfo(__METHOD__,'$beiyongerid',array($beiyongerid));
		if(isset($beiyongerid)===false){return createarrerr('error_code','beiyongerid 不能为空',$info);}//防止NULL
		
		$beiyonger=M('beiyonger');
		$beiyongero=$beiyonger->where('beiyongerid='.$beiyongerid)->find();

		
		return createarrok('ok',$beiyongero,'',$info);
	}

	// //公版
	// public function getmls(){
	// 	$info=collectinfo(__METHOD__,'',array());
	// 	$beiyonger=M('beiyonger');
	// 	$beiyongerls=$beiyonger->join('tb_bd ON f_beiyonger_bdid=bdid')->select();
	// 	return createarrok('ok',$beiyongerls,'',$info);
	// }

	// //公版
	// public function getmlsbybdid($bdid){
	// 	$info=collectinfo(__METHOD__,'$bdid',array($bdid));
	// 	if(isset($bdid)===false){return createarrerr('error_code','bdid 不能为空',$info);}//防止NULL

	// 	$beiyonger=M('beiyonger');
	// 	$beiyongerls=$beiyonger->join('tb_bd ON f_beiyonger_bdid=bdid')->where('f_beiyonger_bdid='.$bdid)->select();

	// 	return createarrok('ok',$beiyongerls,'',$info);
	// }
	
	// //公版
	// public function deletebybdid($bdid){
	// 	$info=collectinfo(__METHOD__,'$bdid',array($bdid));
	// 	if(isset($bdid)===false){return createarrerr('error_code','bdid 不能为空',$info);}//防止NULL
		
	// 	$arr_beiyongerls=$this->getmlsbybdid($bdid);$beiyongerls=$arr_beiyongerls['data'];
	// 	foreach($beiyongerls as $beiyongerv){
	// 		$this->delete($beiyongerv['beiyongerid']);
	// 	}

	// 	return createarrok('ok',$data,'',$info);
	// }

	// //公版
	// public function delete($beiyongerid){
	// 	$info=collectinfo(__METHOD__,'$beiyongerid',array($beiyongerid));
	// 	if(isset($beiyongerid)===false){return createarrerr('error_code','beiyongerid 不能为空',$info);}//防止NULL
		
	// 	$beiyonger=M('beiyonger');$bdbeiyonger=D('Ccbeiyonger');
	// 	$beiyonger->where('beiyongerid='.$beiyongerid)->delete();
	// 	//删除依赖
 //      	$bdbeiyonger->deletebybeiyongerid($beiyongerid);
      	
	// 	return createarrok('ok',$data,'',$info);
	// }

	//公版
	public function add($get){
		$info=collectinfo(__METHOD__,'$get',array($get));
		if(isset($get)===false){return createarrerr('error_code','get 不能为空',$info);}//防止NULL
		
		$beiyonger=M('beiyonger');
		$beiyonger->data($get)->add();

		return createarrok('ok',$data,'',$info);
	}

	//公版
	public function mdf($get,$id){
		$info=collectinfo(__METHOD__,'$get,$id',array($get,$id));
		if(isset($get)===false){return createarrerr('error_code','get 不能为空',$info);}//防止NULL
		if(isset($id)===false){return createarrerr('error_code','beiyongerid 不能为空',$info);}//防止NULL

		$beiyonger=M('beiyonger');
		$beiyonger->where('beiyongerid='.$id)->setField($get);

		return createarrok('ok',$data,'',$info);
	}

	//
	public function addbeiyongercnt($origincnt,$beiyongerid){
		$info=collectinfo(__METHOD__,'$origincnt,$beiyongerid',array($origincnt,$beiyongerid));
		if(isset($origincnt)===false){return createarrerr('error_code','origincnt 不能为空',$info);}//防止NULL
		if(isset($beiyongerid)===false){return createarrerr('error_code','beiyongerid 不能为空',$info);}//防止NULL

		$beiyonger=M('beiyonger');
		$nwcnt=$origincnt+1;
		$dt=array('beiyongercnt'=>$nwcnt);
		$beiyonger->where('beiyongerid='.$beiyongerid)->setField($dt);

		return createarrok('ok',$nwcnt,'',$info);
	}



} 
?>